import path from 'path';
import customRoutes from './customRoutes';

const config = {
  projectName: 'follow-up-wx-doctor',
  date: '2022-03-01',
  designWidth: 375,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2,
    375: 2 / 1,
  },
  sourceRoot: 'src',
  outputRoot: 'dist/follow-up-wx-doctor',
  plugins: [],
  defineConstants: {},
  copy: {
    patterns: [
      {
        from: 'src/MP_verify_TS6dVq0U1ZmchRjl.txt',
        to: 'dist/follow-up-wx-doctor/MP_verify_TS6dVq0U1ZmchRjl.txt',
      },
    ],
    options: {},
  },
  compilerOptions: {
    baseUrl: '.',
  },
  framework: 'react',
  alias: {
    '@/components': path.resolve(__dirname, '..', 'src/components'),
    '@/utils': path.resolve(__dirname, '..', 'src/utils'),
    '@/hooks': path.resolve(__dirname, '..', 'src/hooks'),
    '@/store': path.resolve(__dirname, '..', 'src/store'),
    '@/services': path.resolve(__dirname, '..', 'src/services'),
    '@': path.resolve(__dirname, '..', 'src'),
  },
  csso: {
    enable: false,
  },
  h5: {
    staticDirectory: 'static',
    esnextModules: ['taro-ui'],
    router: {
      mode: 'browser',
      customRoutes,
    },
    // imageUrlLoaderOption: {
    //   limit: 5000,
    //   name: 'static/[name].[ext]',
    // },
    postcss: {
      autoprefixer: {
        enable: true,
        config: {},
      },
      cssModules: {
        enable: true, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: 'module', // 转换模式，取值为 global/module
          generateScopedName: '[name]__[local]___[hash:base64:5]',
        },
      },
    },
  },
};
module.exports = merge => {
  console.error('NODE_ENV:-----', process.env.NODE_ENV);
  console.error('APP_ENV:-----', process.env.APP_ENV);
  if (process.env.NODE_ENV === 'development') {
    return merge({}, config, require('./dev'));
  }
  return merge({}, config, require('./prod'));
};
